export function getStyleNumber(val: any, defaultVal: any) {
  if (val) {
    const t = parseFloat(val);
    if (!isNaN(t)) {
      return t;
    }
  }

  return defaultVal;
}

export function getTmpObjects(data: any) {
  let tmpObjects: any[] = [];

  function traverse(arr: any) {
    for (let item of arr) {
      if (item.type === 'tmp') {
        tmpObjects.push(item);
      }
      if (item.tasks && item.tasks.length > 0) {
        traverse(item.tasks);
      }
    }
  }

  traverse(data);
  return tmpObjects;
}

export function getUrlParams(key:string, url = '') {
  url = url || location.href
  const params = new URLSearchParams(new URL(url).search);
  return params.get(key);
}